package com.shop.service.impl;

import com.github.pagehelper.PageInfo;
import com.shop.entity.Banner;
import com.shop.mapper.BannerMapper;
import com.shop.service.BannerService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author XCH
 * @date 2025 - 06 - 18
 */
@Service("bannerService")
@RequiredArgsConstructor
@Transactional(rollbackFor = RuntimeException.class,
        propagation = Propagation.REQUIRED)
public class BannerServiceImpl implements BannerService {
    private final BannerMapper bannerMapper;
    @Override
    public PageInfo<Banner> listBanner(Integer pageNum, Integer pageSize) {
        List<Banner> list = bannerMapper.listBanner(pageNum, pageSize);
        return new PageInfo<>(list);
    }

    @Override
    public void addBanner(Banner banner) {
        bannerMapper.addBanner(banner);
    }

    @Override
    public void deleteBanner(Integer id) {
        bannerMapper.deleteBanner(id);
    }

    @Override
    public void updateBanner(Banner banner) {
        bannerMapper.updateBanner(banner);
    }
}
